home *** CD-ROM | disk | FTP | other *** search
- #ifndef _gstream_h
- #define _gstream_h
-
- #define gs_BUFSIZE 4096
- #define gs_PRINTFMAX 511
-
- /* just to ensure that if stdio hasn't been included EOF is still
- * defined
- */
-
- #include "flex.h"
- #include <stdio.h>
-
- typedef enum {
- READ,
- WRITE,
- INTERNAL_READ,
- INTERNAL_WRITE
- } gs_type;
-
- typedef size_t (*gswritehandler) ( void *ptr, size_t nbytes, void *stream);
- typedef size_t (*gsreadhandler) ( void *ptr, size_t nbytes, void *stream);
- typedef int (*gsclosehandler) ( void *stream);
-
- /* does anyone out there know how I can get the compiler to accept
- * gstream *stream instead of the messy void * in the three typedefs
- * above? :-(
- */
-
- typedef struct {
- void *buffer;
- int bufsize, size;
- int pos;
- int error;
- int ungetsize;
- void *ungetbuf;
- int ungetpos;
- gs_type type;
- union
- {
- gsreadhandler read;
- gswritehandler write;
- } io;
- gsclosehandler close;
- void *data;
- } gstream;
-
- /* exported function definitions for the gstream module follow */
-
- extern int gsgetbuf(flex_ptr anchor, size_t maxsize, size_t minsize);
- extern int gsflush(gstream *to);
- extern int gsclose(gstream *stream);
- extern int gsgetc(gstream *gs);
- extern int gsputc(int c, gstream *gs);
- extern size_t gsread(void *ptr, size_t size, size_t nmemb, gstream *stream);
- extern size_t gswrite(void *ptr, size_t size, size_t nmemb, gstream *stream);
- extern int gsputs(const char *s, gstream *stream);
- extern char *gsgets(char *s, int n, gstream *stream);
- extern int gsprintf(gstream *stream, const char *format, ...);
- extern int gsungetc(int c, gstream *stream);
- extern int gseof(gstream *stream);
- extern int gsopeninternalr(gstream *stream);
- extern int gsopeninternalw(gstream *stream);
- extern void gsdiscardinternal(gstream *stream);
- extern int gserror(gstream *stream);
- #endif
-